home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / lds / parseargs.c < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  195 lines

  1. /*************************************************************************
  2.  *                                                                       *
  3.  *  Copyright (c) 1992, 1993 Ronald Joe Record                           *
  4.  *                                                                       *
  5.  *  All rights reserved. No part of this program or publication may be   *
  6.  *  reproduced, transmitted, transcribed, stored in a retrieval system,  *
  7.  *  or translated into any language or computer language, in any form or *
  8.  *  by any means, electronic, mechanical, magnetic, optical, chemical,   *
  9.  *  biological, or otherwise, without the prior written permission of:   *
  10.  *                                                                       *
  11.  *      Ronald Joe Record (408) 458-3718                                 *
  12.  *      212 Owen St., Santa Cruz, California 95062 USA                   *
  13.  *                                                                       *
  14.  *************************************************************************/
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <sys/types.h>
  20. #include "defines.h"
  21. #include "externals.h"
  22.  
  23. /* external routines called in this file */
  24. extern void usage();
  25.  
  26. void
  27. parseargs(ac, av)
  28. int ac;
  29. char **av;
  30. {
  31.     int c;
  32.     extern int optind;
  33.     extern char *optarg;
  34.  
  35.     valinit = strdup("xxx");
  36.     while ((c = getopt(ac, av,
  37.         "2Ax:cvepmPqsub:B:r:C:D:E:R:F:h:H:w:W:n:o:i:L:N:M:T:U:"))!=EOF)
  38.     {    switch(c)
  39.         {
  40.         case '2':
  41.             ++two_dim;
  42.             break;
  43.         case 'u':
  44.             usage();
  45.             exit(0);
  46.         case 'c':
  47.             ++cflag;
  48.             break;
  49.         case 'C':
  50.             if (*optarg == 'r')
  51.                 rancon++;                /* random connection strengths */
  52.             else if (*optarg == 'l')
  53.                 lincon++;                /* linear connection strengths */
  54.             else if (*optarg == 'p') {
  55.                 optarg++;
  56.                 G = atoi(optarg);
  57.                 percon++;                /* periodic connection strengths */
  58.             }
  59.             else
  60.                 EC = atof(optarg);
  61.             break;
  62.         case 'D':
  63.             ED = atof(optarg);
  64.             break;
  65.         case 'E':
  66.             ++Eflag;
  67.             erate = atof(optarg);
  68.             break;
  69.         case 'p':
  70.             ++pflag;
  71.             break;
  72.         case 's':
  73.             ++sflag;
  74.             break;
  75.         case 'A':
  76.             ++hflag;
  77.             break;
  78.         case 'o':
  79.             outname = optarg;
  80.             oflag++;
  81.             break;
  82.         case 'e':
  83.             ++eflag;
  84.             break;
  85.         case 'm':
  86.             ++mflag;
  87.             break;
  88.         case 'P':
  89.             ++Pflag;
  90.             break;
  91.         case 'L':
  92.             EL = atof(optarg);
  93.             break;
  94.         case 'R':
  95.             ER = atof(optarg);
  96.             break;
  97.         case 'T':
  98.             tent=1;
  99.             logistic=0;
  100.             omega=atof(optarg);
  101.             if (!lamvalset)
  102.                 lamval=0.5;
  103.             break;
  104.         case 'U':
  105.             EU = atof(optarg);
  106.             break;
  107.         case 'M':
  108.             logistic=0;
  109.             circle=1;
  110.             if (!lamvalset)
  111.                 lamval=0.1;
  112.             omega = atof(optarg);
  113.             break;
  114.         case 'r':
  115.             RANGE = atof(optarg);
  116.             ORANGE = 1.0 - RANGE;
  117.             break;
  118.         case 'v':
  119.             vflag++;
  120.             break;
  121.         case 'W':
  122.             width = atoi(optarg);
  123.             break;
  124.         case 'w':
  125.             wide = atoi(optarg);
  126.             break;
  127.         case 'H':
  128.             height = atoi(optarg);
  129.             break;
  130.         case 'h':
  131.             high = atoi(optarg);
  132.             break;
  133.         case 'x':
  134.             xflag++;    /* use complex dynamical system mode */
  135.             xavg = atoi(optarg);
  136.             break;        /* state of cell to left is control parameter */
  137.         case 'B':
  138.             if (*optarg == 'r') {
  139.                 periodic=0;
  140.                 boundflag=2;
  141.             }
  142.             else if (*optarg == 'f') {
  143.                 periodic=0;
  144.                 boundflag=1;
  145.             }
  146.             else {
  147.                 boundary = atof(optarg);
  148.                 boundflag=3;
  149.                 periodic=0;
  150.             }
  151.             break;
  152.         case 'n':
  153.             lamvalset++;
  154.             if (*optarg == 'r')
  155.                 ranlam++;
  156.             else if (*optarg == 'l')
  157.                 linlam++;
  158.             else if (*optarg == 'p') {
  159.                 laminit = optarg;
  160.                 perlam++;
  161.                 laminit++;
  162.                 if (*laminit == '\0')
  163.                     A = 1;
  164.                 else
  165.                     while (*laminit != '\0')
  166.                           A = (A*10)+(*laminit++ - '0');
  167.             }
  168.             else
  169.                 lamval = atof(optarg);
  170.             break;
  171.         case 'i':
  172.             iflag++;
  173.             valinit = optarg;
  174.             break;
  175.         case 'b':
  176.             begin = atoi(optarg);
  177.             break;
  178.         case 'F':
  179.             freq = atoi(optarg);
  180.             break;
  181.         case 'q':
  182.             quilt = 0;
  183.             break;
  184.         case '?':
  185.             usage();
  186.             exit(1);
  187.             break;
  188.         }
  189.     }
  190.     if (ac-optind != 0) {
  191.         usage();
  192.         exit(1);
  193.     }
  194. }
  195.